﻿<UserControl x:Class="ScrumFactory.Projects.ProjectSummary"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             xmlns:SF_Ext="clr-namespace:ScrumFactory.Windows.Helpers.Extensions;assembly=ScrumFactory.Windows.Helpers"
             
             xmlns:props="clr-namespace:ScrumFactory.Projects.Properties"    
             
             xmlns:local="clr-namespace:ScrumFactory.Projects"

    
             x:Name="thisView"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800">
    
    

    <SF_Helpers:PanelLayout Title="{Binding PanelName}">

        <!-- TOOLBAR -->
        <SF_Helpers:PanelLayout.Toolbar>
            <ToolBar Grid.Row="0">
                <Menu>
                    <MenuItem Header="{x:Static props:Resources.Start_project}" Command="{Binding Path=StartProjectCommand}"
                              Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/startProject.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="{x:Static props:Resources.Close_project}" Command="{Binding Path=CloseProjectCommand}"
                              Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/closeProject.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>                    
                    </MenuItem>
                    <MenuItem Header="{x:Static props:Resources.Reports}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/preview.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                        <MenuItem.Items>
                            <MenuItem Header="{x:Static props:Resources.Sprint_review}" Command="{Binding ShowReportCommand}" CommandParameter="REVIEW"/>
                            <MenuItem Header="{x:Static props:Resources.Project_indicators_report}" Command="{Binding ShowReportCommand}" CommandParameter="INDICATORS"/>
                            <MenuItem Header="{x:Static props:Resources.Project_scope_report}" Command="{Binding ShowReportCommand}" CommandParameter="SCOPE"/>
                            <MenuItem Header="{x:Static props:Resources.Project_guide_report}" Command="{Binding ShowReportCommand}" CommandParameter="GUIDE"/>
                        </MenuItem.Items>
                    </MenuItem>
                    <MenuItem Header="{x:Static props:Resources.Project_details}" Command="{Binding EditProjectCommand}"
                              Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/projectProperties.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem                                
                        Header="{x:Static props:Resources.Suspended}"
                        IsCheckable="True"
                        IsChecked="{Binding IsSuspended}"
                        IsEnabled="{Binding CanEdit}"
                        Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/pause.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <MenuItem                                
                        Header="{x:Static props:Resources.Send_Mail}"
                        Command="{Binding SendMailCommand}"
                        Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/email.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </Menu>

                <MenuItem 
                        Header="{x:Static props:Resources.Doc_rep}" 
                        ToolTip="{Binding DocRep}"
                        Command="{Binding ShowRepositoryCommand}" CommandParameter="{Binding DocRep}">
                    <MenuItem.Icon>
                        <Image Source="/Images/Toolbar/folder.png" Width="32" Height="32" Stretch="Uniform" />
                    </MenuItem.Icon>
                    <MenuItem.Style>
                        <Style TargetType="MenuItem" BasedOn="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Project.DocRepositoryPath}" Value="{x:Null}">
                                    <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Project.DocRepositoryPath}" Value="">
                                    <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>


                <MenuItem 
                        Header="{x:Static props:Resources.Code_rep}" 
                        ToolTip="{Binding CodeRep}"
                        Command="{Binding ShowRepositoryCommand}" CommandParameter="{Binding CodeRep}">
                    <MenuItem.Icon>
                        <Image Source="/Images/Toolbar/repfolder.png" Width="32" Height="32" Stretch="Uniform" />
                    </MenuItem.Icon>
                    <MenuItem.Style>
                        <Style TargetType="MenuItem" BasedOn="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding CodeRep}" Value="{x:Null}">
                                    <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding CodeRep}" Value="">
                                    <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>

                <ItemsControl
                        ItemsSource="{Binding CodeRepositories}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>

                    <ItemsControl.ItemTemplate>
                        <DataTemplate>                           
                            <MenuItem 
                                    
                                    Command="{Binding Model.CreateCodeRepCommand, ElementName=thisView}" CommandParameter="{Binding .}">
                                <MenuItem.Header>                                    
                                    <TextBlock FontSize="{StaticResource SmallFontSize}" Foreground="{StaticResource ToolBarItemBrush}" TextWrapping="Wrap" FontWeight="Normal" TextAlignment="Center"
                                        Text="{Binding RepositoryTypeName, StringFormat={x:Static props:Resources.Create_N_repository}}"/>
                                </MenuItem.Header>
                                <MenuItem.Icon>
                                    <Image Source="{Binding RepositoryImage, Converter={StaticResource ImageSourceConverter}, ConverterParameter='/Images/CodeReps/{0}.png'}" Width="32" Height="32" Stretch="Uniform" />
                                </MenuItem.Icon>
                            </MenuItem>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.Style>
                        <Style>
                            <Setter Property="ItemsControl.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding CodeRep}" Value="{x:Null}">
                                    <Setter Property="ItemsControl.Visibility" Value="Visible"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding CodeRep}" Value="">
                                    <Setter Property="ItemsControl.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ItemsControl.Style>
                </ItemsControl>
            </ToolBar>
        </SF_Helpers:PanelLayout.Toolbar>

        <!-- CONTENT -->
        <SF_Helpers:PanelLayout.Content>
            <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
                <Grid ClipToBounds="False" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width=".3*" MinWidth="240" x:Name="rightColumn" />
                    </Grid.ColumnDefinitions>


                    <StackPanel Orientation="Vertical" Grid.Column="0" Panel.ZIndex="1">

                       
                        
                        <TextBlock Text="{Binding CurrentSprintLabel}" TextWrapping="Wrap"
                           Style="{StaticResource TitleTextBlock}" 
                           Margin="0,5,0,10"/>

                        <local:SummaryHelp />

                        <TabControl>
                            <TabControl.Items>
                                <TabItem Header="{x:Static props:Resources.Project_Burndown}" IsSelected="{Binding BurndownTabIsSelected}" >
                                    <ContentPresenter            
                                    HorizontalAlignment="Stretch" Height="240" VerticalAlignment="Top"                    
                                    Content="{Binding BurndownViewModel.View}"/>
                                </TabItem>
                                <TabItem Header="{x:Static props:Resources.Project_Hours_graph}">
                                    <ContentPresenter            
                                    HorizontalAlignment="Stretch" Height="240" VerticalAlignment="Top"                    
                                    Content="{Binding HoursGraphViewModel.View}"/>
                                </TabItem>
                            </TabControl.Items>
                            <TabControl.Style>
                                <Style TargetType="TabControl" BasedOn="{StaticResource {x:Type TabControl}}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Project.IsTicketProject}" Value="True">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                        <!--<DataTrigger Binding="{Binding ShowHelp_CreateProject}" Value="True">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger>-->

                                    </Style.Triggers>
                                </Style>
                            </TabControl.Style>
                        </TabControl>


                        <!-- INDICATORS -->
                        <Grid Margin="0,15,0,0">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width=".3*"/>
                                <ColumnDefinition Width=".3*"/>
                                <ColumnDefinition Width=".3*"/>
                            </Grid.ColumnDefinitions>

                            <Grid Grid.Column="0" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                    <RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>
                                <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                               Style="{StaticResource ItemGroupTextBlock}"                               
                                Text="{x:Static props:Resources.Budget}"/>
                                <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding BudgetIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.BudgetIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.used_budget}"/>                        
                            </TextBlock>
                                <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{x:Static props:Resources.budgetIndicator_tooltip}"/>
                            </Grid>


                            <Grid Grid.Column="1" Margin="10,0,10,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                    <RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>
                                <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                                Style="{StaticResource ItemGroupTextBlock}"                                
                                Text="{x:Static props:Resources.Quality}"/>
                                <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding QualityIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.QualityIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.re_work}"/>                        
                            </TextBlock>
                                <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{x:Static props:Resources.qualityIndicator_tooltip}"/>
                            </Grid>

                            <Grid Grid.Column="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                    <RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>
                                <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                                Style="{StaticResource ItemGroupTextBlock}"                                
                                Text="{x:Static props:Resources.Speed}"/>
                                <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding VelocityIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.VelocityIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.pts_hrs}"/>                        
                            </TextBlock>
                                <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{Binding FactoryVelocityIndicator, StringFormat={x:Static props:Resources.velocityIndicator_tooltip}}"/>
                            </Grid>

                            <!--<Grid.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ShowHelp_CreateProject}" Value="True">
                                        <Setter Property="Grid.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Style>-->

                        </Grid>







                    </StackPanel>

                    <StackPanel Orientation="Vertical" Grid.Column="1" Margin="40,0,0,0"  VerticalAlignment="Top"  Panel.ZIndex="2">


                        <TextBlock
                        Text="{x:Static props:Resources.My_engagement}"
                        Style="{StaticResource ItemGroupTextBlock}"/>

                        <ListBox
                            
                        HorizontalAlignment="Stretch"
                        ItemContainerStyle="{StaticResource NoSelectionListBoxItem}"
                        ItemsSource="{Binding UserEngages}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Margin="0,3,0,3" Width="240">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <ComboBox                     
                                        Grid.Column="0" VerticalAlignment="Center" Margin="0,0,10,0"
                                        Style="{StaticResource MemberAllocationComboBox}"
                                        SF_Comp:CommandBehavior.RoutedEventName="SelectionChanged"  
                                        SF_Comp:CommandBehavior.TheCommandToRun="{Binding Model.ChangeUserEngageCommand, ElementName=thisView}"
                                        SF_Comp:CommandBehavior.TheCommandParameter="{Binding .}"
                                        SelectedValue="{Binding DayAllocation}">
                                        </ComboBox>
                                        <WrapPanel Orientation="Horizontal" Grid.Column="1" MinHeight="28" >
                                            <TextBlock Style="{StaticResource dayAllocationTextBlock}" DataContext="{Binding DayAllocation}"/>
                                            <TextBlock Text="{x:Static props:Resources._hrs_as_}"/>
                                            <TextBlock Text="{Binding Role.RoleName}" FontWeight="Normal" TextWrapping="Wrap" />
                                        </WrapPanel>

                                        <DockPanel Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Style="{StaticResource ItemActionMenu}">
                                            <Button 
                                            DockPanel.Dock="Right"
                                            Style="{StaticResource RemoveActionButton}"
                                            Command="{Binding Model.RemoveUserEngageCommand, ElementName=thisView}"
                                            CommandParameter="{Binding .}"/>
                                        </DockPanel>

                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        
                        <TextBlock
                        Text="{Binding HoursInThisProject, StringFormat={x:Static props:Resources.N_worked_hours}}"                       
                        FontWeight="Normal"
                        HorizontalAlignment="Center" Margin="0,0,0,10"/>

                        <TextBlock Width="180" TextWrapping="Wrap" HorizontalAlignment="Center">
                        <TextBlock Text="{x:Static props:Resources.You_are_not_in_this_project_team}" TextWrapping="Wrap" Margin="0,0,0,7"/>
                        <LineBreak/>
                        <Hyperlink Command="{Binding JoinProjectCommand}">
                            <Run FontSize="{StaticResource SmallFontSize}" Text="{x:Static props:Resources.Click_here_to_join_the_project}" />
                        </Hyperlink>
                        <TextBlock.Style>
                            <Style>
                                <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding UserEngages.Count}" Value="0">
                                        <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>

                        <Separator HorizontalAlignment="Stretch" Height="2" Margin="10,10,0,10" />

                        <TextBlock Text="{x:Static props:Resources.Scrum_Master}"
                            Style="{StaticResource ItemGroupTextBlock}" Margin="0,0,0,10"/>
                        <ContentControl                                
                                DataContext="{Binding ProjectScrumMaster}"
                                Width="60" Height="60" Padding="6" 
                                HorizontalAlignment="Center" VerticalAlignment="Top"
                                Style="{StaticResource MemberImageControlStyle}"/>
                        <TextBlock Text="{Binding ProjectScrumMaster.FullName}" HorizontalAlignment="Center" Margin="10,5,0,5"/>

                        <ContentPresenter Content="{Binding ArtifactListViewModel.View}"/>


                    </StackPanel>


                </Grid>
            </ScrollViewer>
            
           
            
        </SF_Helpers:PanelLayout.Content>
    </SF_Helpers:PanelLayout>

</UserControl>
